import { getAjax, deleteAjax } from '@/utils/request'

import { Action } from 'vuex'

export interface Online{
  /** 会话编号 */
  tokenId: string;
  /** 用户名称 */
  userName: string;
  /** 登录IP地址 */
  ipaddr: string;
  /** 登录地址 */
  loginLocation: string;
  /** 浏览器类型 */
  browser: string;
  /** 操作系统 */
  os: string;
  /** 登录时间 */
  loginTime: number;
}
export interface StateType {
  data: unknown;
}

export interface ModuleType {
  namespaced: boolean;
  state: StateType;
  mutations: {
  };
  actions: {
    getList: Action<StateType, StateType>;
    forceLogout: Action<StateType, StateType>;
  };
}

const storeModel: ModuleType = {
  namespaced: true,
  state: {
    data: null
  },
  mutations: {
  },
  actions: {
    getList(_, data) {
      return getAjax('/monitor/online/list', data)
    },
    forceLogout(_, tokenId) {
      return deleteAjax(`/monitor/online/${tokenId}`, null)
    }
  }
}

export default storeModel
